extends Node

signal fishing_started
signal fishing_completed(success: bool)

var is_fishing := false
var fishing_area: Area2D = null
var fishing_ui: Control = null
var player: CharacterBody2D = null

func start_fishing(area: Area2D, ui: Control, p: CharacterBody2D):
	if is_fishing:
		return
	
	is_fishing = true
	fishing_area = area
	fishing_ui = ui
	player = p
	
	fishing_started.emit()
	fishing_ui.start_fishing()

func end_fishing(success: bool):
	is_fishing = false
	fishing_completed.emit(success)
	
	if fishing_ui:
		fishing_ui.hide_fishing()
	
	if success and player:
		give_fishing_reward()

func give_fishing_reward():
	# 使用钓鱼奖励系统给予奖励
	var fishing_rewards = preload("res://scripts/fishing/fishing_rewards.gd")
	var reward = fishing_rewards.give_fishing_reward(player)
	print("钓到了: %s" % reward["name"])
